package com.liy.cloud.base.service.impl;

import com.liy.cloud.base.dao.BaseTypePartDao;
import com.liy.cloud.base.entity.BaseTypePartEntity;
import com.liy.cloud.base.service.BaseTypePartService;
import com.das.framework.common.dao.IBaseDao;
import com.das.framework.common.service.impl.BaseServiceImpl;

import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * @Auther: libs
 * @Date: 2018/6/27 20:25
 * @Description: 部件种类-部件关联Service实现类
 */
@Service
public class BaseTypePartServiceImpl extends BaseServiceImpl<BaseTypePartEntity, String> implements BaseTypePartService {

    @Resource
    private BaseTypePartDao baseTypePartDao;

    @Override
    public IBaseDao<BaseTypePartEntity, String> getDao() {
        return baseTypePartDao;
    }

    @Override
    public void save(List<BaseTypePartEntity> typePartList,String typeId) throws Exception {

        //先删除原有关系，再插入新的关系
        baseTypePartDao.deleteByTypeId(typeId);

        for(BaseTypePartEntity entity: typePartList){
            baseTypePartDao.insertSelective(entity);
        }
    }
}
